package com.tanhua.dubbo.server.controller;

import com.tanhua.common.utils.NoAuthorization;
import com.tanhua.dubbo.server.service.ManagerVideoService;
import com.tanhua.dubbo.server.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;



@RestController
@RequestMapping("/manage")//一级请求路径
public class ManagerVideoController {
    //注入业务层
    @Autowired
    private ManagerVideoService managerVideoService;

    /*根据用户id查询所有视频列表*/
    @NoAuthorization
    @GetMapping("/videos")//二级请求路径
    public ResponseEntity videos(@RequestParam(defaultValue = "1") Integer page,
                                 @RequestParam(defaultValue = "10") Integer pagesize,
                                 Long uid, String sortProp, String sortOrder) {

        //使用注入的service调用里面的查询视频方法,传入前端传过来的5个参数(page, pagesize, uid,sortProp,sortOrder)
        PageResult result = managerVideoService.findAllVideos(page, pagesize, uid, sortProp, sortOrder);
        //返回结果
        return ResponseEntity.ok(result);

    }
}
